import { useDispatch, useSelector } from 'react-redux'
import { RootState, RootThunkAction } from '@/types/store'
import { useEffect } from 'react'
export function useInitialState(action: () => RootThunkAction) {
  const dispatch = useDispatch()

  useEffect(() => {
    dispatch(action())
  }, [dispatch, action])

  const state = useSelector((state: RootState) => state)
  return state
}
